﻿using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        /// <summary>
        /// GetJob is used to collect the tasks to finish the order creation
        /// </summary>
        /// <param name="FInterID"></param>
        /// <returns></returns>
        private void VALBTYP(DataSet db)
        {

            DataSet Result = new DataSet();
            DataSet Return = new DataSet();
            string TXTISIND = "", VAART = "", WAFBRTL = "", WAFBRTU = "", WARGRLFD = "", WIDTH = "", WAFGRQM = "", VAAMENGEH = "";
            try
            {
                string CellValue = "";
                Helpers.Helper.GetDate(ref date, ref year, ref month, ref day);
                int rown = 10;
                int idx = 0;
                int xStart = 0;
                int count = db.Tables["VAART"].Rows.Count;
                foreach (DataRow dwVA in db.Tables["VAART"].Rows)
                {
                    exAgent.SetCellValue(xStart + idx * rown + 1, 1, "AURORA FASHIONS ASIA LIMITED");
                    exAgent.SetCellValue(xStart + idx * rown + 2, 1, "ART NO.:");
                    exAgent.SetCellValue(xStart + idx * rown + 3, 1, "COMP:");
                    exAgent.SetCellValue(xStart + idx * rown + 5, 1, "WEIGHT:");
                    exAgent.SetCellValue(xStart + idx * rown + 6, 1, "REMARKS:");
                    exAgent.SetCellValue(xStart + idx * rown + 7, 1, "LOCATION:");
                    exAgent.SetCellValue(xStart + idx * rown + 5, 14, "WIDTH:");
                    exAgent.SetCellValue(xStart + idx * rown + 6, 14, "CODE:");
                    exAgent.SetCellValue(xStart + idx * rown + 7, 14, "BOOK:");
                    VAART = dwVA["VAADART"].ToString();
                    WIDTH = dwVA["WIDTH"].ToString();
                    exAgent.SetCellValue(xStart + idx * rown + 5, 17, WIDTH);

                    WAFGRQM = dwVA["WEIGHT"].ToString();
                    exAgent.SetCellValue(xStart + idx * rown + 5, 5, WAFGRQM);
                    CellValue = dwVA["VAABEZ"].ToString().Trim();

                    exAgent.SetCellValue(xStart + idx * rown + 2, 5, CellValue);
                    CellValue = dwVA["VAAART"].ToString().Trim();
                    exAgent.SetCellValue(xStart + idx * rown + 8, 1, "*" + CellValue.Replace('(', '%').Replace(')', '+') + "*");
                    //CellValue = dwData["VAABEZ"].ToString();
                    //exAgent.SetCellValue(2, 5, CellValue); 
                    CellValue = dwVA["VAAFILLER"].ToString();
                    exAgent.SetCellValue(xStart + idx * rown + 3, 5, CellValue);
                    CellValue = dwVA["CODE"].ToString();
                    exAgent.SetCellValue(xStart + idx * rown + 6, 17, CellValue);
                    //exAgent.SetCellValue(8, 1, CellValue);
                    CellValue = dwVA["LOCATION"].ToString();
                    exAgent.SetCellValue(xStart + idx * rown + 7, 5, CellValue);
                    CellValue = dwVA["BOOK"].ToString();
                    exAgent.SetCellValue(xStart + idx * rown + 7, 17, CellValue);
                    CellValue = dwVA["REMARK"].ToString();
                    CellValue = (CellValue.Replace('\r', ' ').Replace('\n', ' ')).Trim();
                    exAgent.SetCellValue(xStart + idx * rown + 6, 5, Helper.GetGB2312Value(CellValue));
                    idx++;
                    if (idx < count)
                    {
                        exAgent.RangeCopy(1, rown, xStart + idx * rown + 1, xStart + rown * (idx + 1), true);

                        //exAgent.RangeCopy(18, 19, xStart + rown * idx, xStart + rown * idx + 1); 
                    }
                }
                exAgent.HideRows(xStart + idx * rown + 1, 1, 9999, 1);
                exAgent.Save();
                exAgent.FileName = DestFile;
                if (PrintType == "PrintEX")
                {
                    DirectPrint(DestFile);
                }
                if (PrintType == "DirectPrint")
                {
                    DirectPrint(DestFile);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {

            }
            return;
        }

    }
}
